#!/usr/bin/perl

my $from = 'test@qmail.info';

my $hosts = ['27.0.0.1','ldap.qmail.info'];

use Net::LDAP;
$ldap = Net::LDAP->new($hosts, timeout=>7);
if ($ldap) {
$mesg = $ldap->bind;
$mesg = $ldap->search(base => 'ou=vusers,dc=qmail,dc=info', 
                    filter => "(&(objectclass=qmailuser)(uid=$from))",
                    attrs => ['smtpThrottle']
);
my @entries = $mesg->entries;
if(@entries) {
  $limit=$entries[0]->get_value('smtpThrottle');
} else {
  $limit = 10;
}
} else {
 $limit = 10;
}
print $limit;
